package utils
{
	import mx.core.UIComponent;
	import mx.logging.ILogger;

	public class UIUtil
	{
		public static var NAME : String = "UIUtil.as";
		private static var log:ILogger =  LogUtil.getInst().getLogger( NAME );
		
		public function UIUtil()
		{
		}
		
		public static function center(target:UIComponent, container:UIComponent):void
		{
			if ( target != null && container != null )
			{
				target.x = (container.width - target.width) * 0.5 ;
				target.y = (container.height - target.height) * 0.5 ;
			}
		}
		
		/**
		 *  将容器设置顶层
		 **/
		public static function setToTop(target:UIComponent, container:UIComponent):void
		{
			if (target != null && container != null && container.contains(target))
			{
//				target.visible = true;					
				var index:int = container.numChildren - 1;			
				container.setChildIndex(target, index);
			}
		}
	}
}